<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .contain {
            width: 600px;
            height: 600px;
            border: 1px solid red;
            display: grid;
            grid-template-columns: repeat(3, 100px);
            grid-template-rows: repeat(3, 100px);
            margin: 100px auto;
            /* 控制整体布局的移动 */
            /* justify-content: center;
            align-content: center; */
            /* 简写 */
            place-content: center end;
        }

        .item {
            width: 50px;
            height: 50px;
            line-height: 50px;
            text-align: center;
        }

        .item:nth-child(even) {
            background-color: pink;
        }

        .item:nth-child(odd){
            background-color: yellow;
        }


    </style>
</head>
<body>
    <div class="contain">
        <!-- <div class="contain1"> -->
            <div class="item">1</div>
            <div class="item">2</div>
            <div class="item">3</div>
            <div class="item">4</div>
            <div class="item">5</div>
            <div class="item">6</div>
            <div class="item">7</div>
            <div class="item">8</div>
            <div class="item">9</div>
        <!-- </div>  -->
    </div>
</body>
</html>